///引入共享头部
import '../../common/shard.dart';

import '../home/home.dart';


class SplashScreen extends StatefulWidget {
	const SplashScreen({Key? key}) : super(key: key);

	@override
	_SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> with TickerProviderStateMixin{

	@override
	void initState() {
	  	super.initState();
        initApp();


	}

    initApp()async{
        ///todo something
		Future.delayed(const Duration(seconds: 2),(){
			Get.offAll(()=>const HomePage(),transition: Transition.noTransition);
		});
    }

    @override
    void dispose() {
        super.dispose();
    }

	@override
	Widget build(BuildContext context) {

		return Scaffold(
			body: Stack(
				children: [
					Center(
						child: SizedBox(
							width: 30.w,
							height:30.w,
							child: const CircularProgressIndicator(),
						),
					),

                    //预加载一个任意emoji,防止后续卡顿
                    Positioned(bottom: 10000,right: 10000,child: FutureBuilder(
                        future: Future.delayed(const Duration(milliseconds: 100)),
                        builder: (context,snapshot){
                            return const Text("😍 ");
                        }
                    ))
				],
			),
		);
	}
}


class ChildWidget extends StatelessWidget {
	@override
	Widget build(BuildContext context) {
		return Container(
		child: TextButton(
			child: Text("Generate error"),
			onPressed: () => generateError(),
		),
		);
	}

	///Simply just trigger some error.
	void generateError() async {
		throw "Test exception";
	}
}
